import request from '/@/utils/request';

export function useDictApi() {
	return {
		// 查询字典数据列表
		listData: (query: any) => {
			return request({
				url: '/system/dict-data/page',
				method: 'get',
				params: query,
			});
		},

		// 查询字典数据详细
		getData: (dictCode: any) => {
			return request({
				url: '/system/dict-data/get?id=' + dictCode,
				method: 'get',
			});
		},

		// 根据字典类型查询字典数据信息
		getDicts: (dictType: any) => {
			return request({
				url: '/system/dict-data/type/' + dictType,
				method: 'get',
			});
		},

		// 新增字典数据
		addData: (data: any) => {
			return request({
				url: '/system/dict-data/create',
				method: 'post',
				data: data,
			});
		},

		// 修改字典数据
		updateData: (data: any) => {
			return request({
				url: '/system/dict-data/update',
				method: 'put',
				data: data,
			});
		},

		// 删除字典数据
		delData: (dictCode: any) => {
			return request({
				url: '/system/dict-data/delete?id=' + dictCode,
				method: 'delete',
			});
		},

		// 导出字典数据
		exportData: (query: any) => {
			return request({
				url: '/system/dict-data/export',
				method: 'get',
				params: query,
				responseType: 'blob',
			});
		},

		// 查询全部字典数据列表
		listSimpleDictDatas: () => {
			return request({
				url: '/system/dict-data/list-all-simple',
				method: 'get',
			});
		},
	};
}
